package main

import (
	"context"
	"fmt"
	"go_rpc/rpc/pb/test"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"log"
)

func main() {
	conn, err := grpc.Dial("localhost:8080", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		fmt.Println("异常:", err.Error())
		panic(err)
	}
	defer conn.Close()

	client := test.NewHelloServiceClient(conn)
	hello, err := client.SayHello(context.Background(), &test.HelloReq{Name: "client"})
	if err != nil {
		fmt.Println("异常:", err.Error())
		panic(err)
	}
	log.Printf("received grpc resp: %+v", hello.String())

}
